package org.JQbitorrentClinet.request.rss;

import com.google.gson.Gson;
import lombok.Builder;
import org.JQbitorrentClinet.utils.HttpClientProxyRequestType;
import org.JQbitorrentClinet.pojo.rss.RssAutoDownloadingRule;
import org.JQbitorrentClinet.base.BaseParam;

import java.util.HashMap;
import java.util.Map;

@Builder
public class RssSetAutoDownloadingRuleParam extends BaseParam {
    String ruleName;
    RssAutoDownloadingRule ruleDef;

    public RssSetAutoDownloadingRuleParam(String ruleName, RssAutoDownloadingRule ruleDef) {
        this.ruleName = ruleName;
        this.ruleDef = ruleDef;
        requestType = HttpClientProxyRequestType.POSTURLENCODED;
    }

    @Override
    public Map getParamMap() {
        Map<String, Object> map = new HashMap<>();
        map.put("ruleName", ruleName);
        map.put("ruleDef", new Gson().toJson(ruleDef));
        return map;
    }

    @Override
    public String getApiUrl() {
        return "/api/v2/rss/setRule";
    }
}
